<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.*,
						com.ophelisis.common.util.*,
						com.ophelisis.common.consts.*"%>
						
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=ConstPath.siteTitle%></title>
<link href="css/common.css" rel="stylesheet" />
<script src="js/jquery-1.7.2.js"></script>
</head>
<body>
<div id="formlist1" class="noborder">
	<form id="commonForm" name="commonForm" method="post">
		<input type="hidden" id="_startRowNo" name="_startRowNo" value="${_startRowNo}" />
		<input type="hidden" id="_pageSize" name="_pageSize" value="8" />
	</form>
	<div id="ajaxDivList" class="noborder"></div>
</div>

<script>
var url = "zipcode.action";
var params = "target=zcList";
var targetElement = "ajaxDivList";

var pmModule = {
		loadList: function() {
			var rParams = params + "&" + $("#commonForm").serialize() + ($("#loadCheck").val() == "OK" ? ($("#isNew").val() == "Y" ? "&searchVal1=" + $("#searchVal1").val() : "&" + $("#searchForm").serialize()) : "");

			this.makeList(url, rParams);
		},
		
		setBinding: function() {
			var that = this;

			$("#searchVal1").keypress(function(e) {
				if (e.keyCode == "13") {
					return false;
				}
			});
			
			$("#searchBtn").bind({
				click: function(e) {
					that.loadList();
				}
			});
		},
		
		setUnbinding: function() {
			$("#searchVal1").unbind();
			$("#searchBtn").unbind();
		},
		
		select: function(zipcode, address) {
			parent.$("#zipcode1").val(zipcode.split("-")[0]);
			parent.$("#zipcode2").val(zipcode.split("-")[1]);
			parent.$("#userZipcode").val(zipcode);
			parent.$("#userAddress").val(address);
			parent.NcloseLayer();
		},
		
		makeList: function(sUrl, sParams) {
			var that = this;
			
			$.ajax({
				url : sUrl,
				type : "POST",
				data : sParams,
				dataType : "html",
				success : function(data){
					$("#" + targetElement).html(data);

					that.setUnbinding();
					that.setBinding();
					parent.sortTable();
			
					if ($("#nodata").html() != null) {
						if ($("#_startRowNo").val() != "0") {
							$("#_startRowNo").val("0");
							loadList();
						} else {
							$("#nodata").css({"height":(parseInt($("#formlist1").css("height").replace("px","")) - 10)});
						}
					}
				}
			});
		}
};

function movePage(startRow) {
	$("#_startRowNo").val(startRow);
	
	pmModule.loadList();
}

$(document).ready(function(){
	pmModule.loadList();
});
</script>
</body>
</html>
